//引入路由组件
import Home from '@/pages/Home/Home.vue'
import Login from '@/pages/Login/Login.vue'
import Search from '@/pages/Search/Search.vue'
import Register from '@/pages/Register/Register.vue'
import Detail from "@/pages/Detail/Detail.vue"
import AddCartSuccess from "@/pages/AddCartSuccess/index.vue"
import ShopCart from "@/pages/ShopCart/index.vue"
import Trade from '@/pages/Trade'
import Pay from '@/pages/Pay'
import PaySuccess from '@/pages/PaySuccess'
import Center from "@/pages/Center"
//引入二级路由组件
import MyOrder from '@/pages/Center/myOrder'
import GroupOrder from '@/pages/Center/groupOrder'

//路由配置信息
export default [
    {
        path:"/center",
        component:Center,
        meta:{
            show:true
        },
        //二级路由组件
        children:[{
            path:"myorder",
            component:MyOrder,
            meta:{
                show:true
            }
        },
        {
            path:"grouporder",
            component:GroupOrder,
            meta:{
                show:true
            }
        },
        {
            path:"/center",
           redirect:"/center/myorder"
        }]
    },
    {
        path:"/paysuccess",
        component:PaySuccess,
        meta:{
            show:true
        }
    },
    {
        path:'/pay',
        component:Pay,
        meta:{
            show:true
        },
        beforeEnter:(to,from,next) => {
            if (from.path == "trade") {
                next()
            }else{
                next(false)
            }
        }
    },
    {
        path:'/trade',
        component:Trade,
        meta:{
            show:true
        },
        //路由独享守卫
        beforeEnter:(to,from,next)=>{
            if (from.path == "/shopcart") {
                next()
            }else{
                next(false)
            }
        }
    },
    {
        path:'/ShopCart',
        component:ShopCart,
        meta:{
            show:true
        },
        name:'ShopCart'
    },
    {
        path:'/addcartsuccess',
        component:AddCartSuccess,
        meta:{
            show:true
        },
        name:'addcartsuccess'
    },
    {
        path: "/detail/:skuId",
        component: Detail,
        meta: {
            show: true
        }
    },
    {
        path: "/home",
        component: Home,
        meta: {
            show: true,
        }
    },
    {
        path: "/login",
        component: Login,
        meta: {
            show: false,
        }
    },
    {
        path: "/search/:keyword?",
        component: Search,
        meta: {
            show: true,
        },
        name: 'search',
        props: true
    },
    {
        path: "/register",
        component: Register,
        meta: {
            show: false,
        }
    },
    //重定向,在项目跑起来的时候,访问/,立马进入首页
    {
        path: "*",
        redirect: "/home"
    }

]